package com.luoxiang.socialandroid.dialog

import android.content.Context
import com.luoxiang.socialandroid.R
import com.luoxiang.socialandroid.databinding.DialogTipBinding
import com.lxj.xpopup.impl.FullScreenPopupView

class TipDialog(context: Context) : FullScreenPopupView(context) {
    private lateinit var mViewBinding: DialogTipBinding
    private var title: String? = null
    private var content: String? = null
    private var cancel: String? = null
    private var confirm: String? = null
    private var onCancelClickListener: (() -> Unit)? = null
    private var onConfirmClickListener: (() -> Unit)? = null

    override fun getImplLayoutId() = R.layout.dialog_tip

    override fun onCreate() {
        super.onCreate()
        mViewBinding = DialogTipBinding.bind(popupImplView)
        mViewBinding.textTitle.text = title
        mViewBinding.textContent.text = content
        mViewBinding.textCancel.text = cancel
        mViewBinding.textConfirm.text = confirm
        mViewBinding.viewCancel.setOnClickListener { onCancelClickListener?.invoke() }
        mViewBinding.viewConfirm.setOnClickListener { onConfirmClickListener?.invoke() }
    }

    fun setTitle(title: String) {
        this.title = title//设置标题
    }

    fun setContent(content: String) {
        this.content = content
    }

    fun setCancel(cancel: String) {
        this.cancel = cancel
    }

    fun setConfirm(confirm: String) {
        this.confirm = confirm
    }

    fun setOnCancelClickListener(onCancelClickListener: () -> Unit) {
        this.onCancelClickListener = onCancelClickListener
    }

    fun setOnConfirmClickListener(onConfirmClickListener: () -> Unit) {
        this.onConfirmClickListener = onConfirmClickListener
    }
}